# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name： tensor_to_numpy
Description :
Author : 'li'
date： 2022/3/14
-------------------------------------------------
Change Activity:
2022/3/14:
-------------------------------------------------
"""


class TensorToNumpy:
    def __init__(self, input_key='img', output_key='img'):
        self.input_key = input_key
        self.output_key = output_key

    def __call__(self, data):
        """

        Args:
            data:

        Returns:

        """
        img = data[self.input_key].clone()
        img = img.detach().cpu().numpy()
        data[self.output_key] = img
        return data


def tensor_to_numpy(data):
    tsf = TensorToNumpy()
    d = dict(img=data)
    d = tsf(d)
    return d['img']
